package com.wcar.product.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wcar.common.entity.ProductType;
import com.wcar.common.util.OssUtil;
import com.wcar.common.vo.Result;
import com.wcar.product.service.impl.ProductTypeServiceImpl;
import com.wcar.product.vo.ProductTypeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/product/type")
public class ProductTypeController {
    @Autowired
    private ProductTypeServiceImpl productTypeService;
    @GetMapping("/selectAllProductType")
    public Result<List<ProductType>> selectAllProductType()
    {
        return productTypeService.selectAllProductType();
    }
    @PostMapping("/select")
    public Result<Page<ProductType>> select(@RequestBody ProductTypeVo productTypeVo) {
        return productTypeService.selectProductType(productTypeVo);
    }
    @PostMapping("/uploadFile")
    public String uploadFile(MultipartFile file) {
        String s = OssUtil.uploadOss(file);
        return s;
    }
    @PostMapping("/updateProductType")
    public Result<ProductType> updateProductType(@RequestBody ProductType productType) {
        return productTypeService.updateProductType(productType);
    }
    @GetMapping("/deleteProductTypeById")
    public Result<ProductType> deleteProductTypeById(@RequestParam Integer commentId) {
        return productTypeService.deleteProductTypeById(commentId);
    }
    @PostMapping("/insertProductType")
    public Result<ProductType> insertProductType(@RequestBody ProductType productType) {
        return productTypeService.insertProductType(productType);
    }
    @PostMapping("/updateIseditByChangeId")
    public Result<Boolean> updateIseditByChangeId(@RequestBody ProductType commentId){
        return productTypeService.updateIseditByChangeId(commentId);
    }
}
